package com.str.graphs;
public class FloydTest {

  private static final int NUM = 4; // Number of vertices
  private static final boolean UNDIRECTED = false;
  
  // Create a graph from array
  public static Graph createGraph(int[][] examp) {
    Graph g = new MatrixGraph(NUM);
   // Graph G = new ListGraph(NUM);

    for (int i=0; i<examp.length; i++) {
      int v1 = examp[i][0];
      int v2 = examp[i][1];
      int dist = 1;  // No weight given -- set at 1       
      if (examp[i].length > 2)
        dist = examp[i][2];
      g.setEdge(v1, v2, dist);
      if (UNDIRECTED) // Also put in edge in other direction
        g.setEdge(v2, v1, dist);
    }
    return g;
  }

  public static void print(Graph g) {
    System.out.println("Number of vertices is " + g.n());
    System.out.println("Number of edges is " + g.e());

    System.out.println("Matrix is:");
    for (int i=0; i<g.n(); i++) {
      for (int j=0; j<g.n(); j++)
        System.out.print(g.weight(i, j) + "  ");
      System.out.println();
    }
    System.out.println();
  }

  // Generic main function for graph tests --
  //   both adjacency list and adjacency graph
  public static void main(String args[]) {
  	
    int[][] examp = {{0, 1,  1},
                     {0, 2,  8},
                     {0, 3, 12},
                     {1, 0,  4},
                     {1, 2,  8},
                     {1, 3,  7},
                     {2, 0,  2},
                     {2, 1,  5},
                     {2, 3, 11},
                     {3, 0,  8},
                     {3, 1,  3},
                     {3, 2,  8}};
    Graph g = createGraph(examp);
    print(g);
    Floyd.floyd(g);
  }
}
